<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<span>预解析会做的两件事</span>
<ol>
    <li>会把var关键字定义的变量在代码执行之前声明变量。</li>
    <li>会把这个函数名在所有代码执行之前声明，并且赋值为一个函数(function)。</li>
</ol>
<script>
    /*var a = 10;
    function test() {
        console.log(a);
        a = 100;
        console.log(this.a);
        var a;
        console.log(a);
    }
    test();*/

    /*var a = 10;
    function f1() {
        var b = 2 * a;
        var a = 20;
        var c = a + 1;
        console.log(b); // NaN
        console.log(c); // 21
    }
    f1();*/

    /*if(!("a" in window)){
        var a = "李玉华";
    }
    alert(a);*/

    /*function fn(){
        alert("我们是全局的fn");
    }
    function fn2(){
        alert(fn);
        fn = 3;
        return;
        function fn(){
            alert("我是fn2里面的");
        }
    }
    fn2();*/

    /*var n = 0;
    function a(){
        var n = 10;
        function b(){
            n++;
            alert(n);
        }
        b();
        return b;
    }
    var c = a();
    c();
    alert(n);*/

    /*var n = 99;
    function outer(){
        var n = 0;
        return function inner(){
            return n++;
        }
    }
    var c = outer();
    var num1 = c();
    var num2 = c();
    var d = outer();
    var num3 = d();
    console.log(num1, num2, num3)*/
</script>
</body>
</html>
